package com.mj;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class Student extends Person<String, Integer>
implements Test1<Integer, Double>, Test2<Double, Long, StringBuilder> {

    // 获取泛型的类型
    public void printGenericType() {
        // 父类
        ParameterizedType superClassType  = (ParameterizedType) getClass().getGenericSuperclass();
        Type[] args = superClassType.getActualTypeArguments();
        for (Type arg : args) {
            System.out.println(arg);
        }

        System.out.println("-----------------------------");

        // 接口
        Type[] interfaceTypes = (Type[]) getClass().getGenericInterfaces();
        for (Type type : interfaceTypes) {
            ParameterizedType interfaceType = (ParameterizedType) type;
            Type[] interfaceArgs = interfaceType.getActualTypeArguments();
            for (Type arg : interfaceArgs) {
                System.out.println(arg);
            }
        }


    }
}
